package org.qiyu.live.id.generate.provider;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.qiyu.live.id.generate.provider.service.IdGenerateService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import java.util.HashSet;
import java.util.Set;

/*
 * 用户中台 dubbo服务提供者
 *
 * */
@SpringBootApplication
@EnableDubbo
@EnableDiscoveryClient
public class IdGenerateApplication{
    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(IdGenerateApplication.class);
        springApplication.setWebApplicationType(WebApplicationType.NONE);
        springApplication.run(args);

    }

//    @Resource
//    private IdGenerateService idGenerateService;
//
//    @Override
//    public void run(String... args) throws Exception {
//        long l = System.currentTimeMillis();
//
//        long mm = 1;
//        while (true) {
//            Long seqId = idGenerateService.getSeqId(1);
//            System.out.println(seqId);
//            mm++;
//            if(System.currentTimeMillis()-l >= 1000){
//                System.out.println(mm);
//                break;
//
//            }
//        }


//        Set a = new HashSet();
//        for (int i = 0; i < 2000; i++) {
//            Long seqId = idGenerateService.getUnSeqId(1);
//            a.add(seqId);
//            System.out.println(seqId);
//        }
//        System.out.println("   ");
//    }
}
